let mongoose = require('mongoose')
let Schema = mongoose.Schema;

let courseSchema = new Schema({
    code : { type : String, match : /^.{6}$/, required: true},
    name : { type : String, match : /^.{1,10}$/, required: true },
    tid: {type : Schema.Types.ObjectId, required: true},
    students: [{type: Schema.Types.ObjectId, ref: 'student', default: []}],
    create_time: {type: Date, default: Date.now},
})

module.exports = mongoose.model('course', courseSchema)